@extends('admin.layout')
@section('content');
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                影评管理
                <small>列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>后台</a></li>
                <li><a href="#">影评管理</a></li>
                <li class="active">列表</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title">快速查看影评列表</h3>
                        </div><!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">               
                            <div class="row">
                                <form accept="{{ url('/admin/psot/index') }}" method="get">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <select name="num" class="form-control">
                                                <option value="10" 
                                                    @if(!empty($request['num']) && $request['num'] == 10)
                                                        selected="selected" 
                                                    @endif
                                                    >10</option>
                                                <option value="15" 
                                                    @if(!empty($request['num']) && $request['num'] == 15)
                                                        selected='selected' 
                                                    @endif
                                                    >15</option>
                                                <option value="50" 
                                                    @if(!empty($request['num']) && $request['num'] == 50)
                                                        selected='selected' 
                                                    @endif
                                                    >50</option>
                                                <option value="100" 
                                                    @if(!empty($request['num']) && $request['num'] == 100)
                                                        selected='selected' 
                                                    @endif
                                                    >100</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-md-offset-2">
                                        <div class="input-group input-group">
                                            <input class="form-control" type="text" name="keyword" value="{{ $request['keyword'] or '' }}">
                                            <span class="input-group-btn">
                                            <button class="btn btn-info btn-flat" type="submit">搜索</button>
                                            </span>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="row" style="height:10px;">
                            </div>
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>电影名称</th>
                                    <th>内容</th>
                                    <th>发表时间</th>
                                    <th>发表评分</th>
                                    <th>发表人</th>
                                    <th>回复量</th>
                                    <th>回收站</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($data as $v)
                                <tr>
                                    <td class="ids">{{ $v -> id }}</td>
                                    <td>{{ $v -> pname }}</td>
                                    <td>{!! $v -> content !!}</td>
                                    <td>{{ $v -> ctime }}</td>
                                    <td>{{ $v -> score }}</td>
                                    <td>{{ $v -> name }}</td>
                                    <td>{{ $v -> couns }}</td>
                                    <td class="lang">
                                            放入回收站
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
@endsection
<!-- page script -->
<script>
    window.onload = function()
    {
        $.ajaxSetup({
            headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        
        //添加事件
        $('.lang').on('click', function(){

            var lang = $(this);

            var id = $(this).parent().find('.ids').html();
            // var id = $(this).parent().children().first().html();

            $.post('/admin/post/ajaxUpdate', {id:id}, function(data){
                if(data == '0')
                {
                    lang.html('<li class="fa fa-check" style="color:green;"></li>已放入回收站')
                }else
                {
                    alert('放入失败');
                }
            }, 'json');

        });

    }
</script>